package com.java.base.classloader;

import java.lang.reflect.Field;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;

public class LoadOrder {

    PrintClassLoader printClassLoader = null;
    static XClassLoader xClassLoader = null;

    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        System.out.println("ok");
        printAllClass(ClassLoader.getSystemClassLoader());
        XClassLoader xClassLoader = null;
        System.out.println("=====");
        printAllClass(ClassLoader.getSystemClassLoader());
        System.out.println("end");

    }


    @SuppressWarnings("unchecked")
    public static void printAllClass(ClassLoader classLoader) throws NoSuchFieldException, IllegalAccessException {
        Field f = ClassLoader.class
                .getDeclaredField("classes");
        f.setAccessible(true);
        ((Vector<Class<?>>) f.get(classLoader))
                .forEach((clz) -> System.out.println(clz.getName()));
    }

}
